package com.zhiyan.security.account.dao;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.zhiyan.common.util.exception.DaoException;
import com.zhiyan.security.account.dao.mapper.AccountMapper;
import com.zhiyan.security.account.domain.entity.Account;

@Repository
public class AccountDao {
	@Autowired
	AccountMapper accountMapper;
	
	/**
	 * 新增
	 * @param account
	 */
	public void add(Account account){
		try {
			accountMapper.add(account);
		} catch (Exception e) {
			throw new DaoException(e.getMessage(), e);
		}
	}
	
	/**
	 * 更新
	 * @param account
	 */
	public void update(Account account){
		try {
			accountMapper.update(account);
		} catch (Exception e) {
			throw new DaoException(e.getMessage(), e);
		}
	}
	
	/**
	 * 条件查询
	 * @param map
	 * @return
	 */
	public List<Account> query(Map<String, Object> map) {
		try {
			List<Account> list = accountMapper.query(map);
			return list;
		} catch (Exception e) {
			throw new DaoException(e.getMessage(), e);
		}
	}

	/**
	 * 假删除
	 * @param idList
	 */
	public void delete(List<String> idList){
		try {
			accountMapper.delete(idList);
		} catch (Exception e) {
			throw new DaoException(e.getMessage(), e);
		}
	}
}
